package Tools
{
	import flash.utils.ByteArray;

	public class StringTool 
	{
		public static function strLength(str:String):int
		{
			var byte:ByteArray=new ByteArray();
			byte.writeMultiByte(str,"gb2312");
			return byte.length;
		}
		public static function isNumber(str:String):Boolean
		{
			var index:int=0;
			while(index<str.length)
			{
				var code:int=str.charCodeAt(index);
				if(code<=47||code>=58)
				{
					return false;
				}
				index++;
			}
			
			return true;
		}
		public static function horizToVert(str:String):String
		{
			var arr:Array=new Array();
			
			var index:int=0;
			while(index<str.length)
			{
				arr.push(str.charAt(index));
				index++;
			}
			
			return arr.join("<br>");
		}
		public static function StringToBytes(str:String,len:int=-1):ByteArray
		{
			var byteArr:ByteArray = new ByteArray();
			byteArr.writeMultiByte(str,"gb2312");
			if(len!=-1)
			{
				byteArr.length = len;
			}
			return byteArr;
		}
	}
}
